use cargo::core::Workspace;
-use cargo::ops;
+use cargo::ops::{self, MessageFormat};
use cargo::util::{CliResult, CliError, Human, Config, human};
use cargo::util::important_paths::{find_root_manifest_for_wd};
flag_verbose: u32,
flag_quiet: Option<bool>,
flag_color: Option<String>,
- flag_message_format: Option<String>,
+ flag_message_format: MessageFormat,
flag_lib: bool,
flag_bin: Vec<String>,
flag_example: Vec<String>,
-v, --verbose ... Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
- --message-format FMT Error format: human, json-v1
+ --message-format FMT Error format: human, json [default: human]
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
&options.flag_color,
options.flag_frozen,
options.flag_locked));
- let message_format = try!(ops::MessageFormat::from_option(
- &options.flag_message_format
- ));
let ops = ops::TestOptions {
no_run: options.flag_no_run,
no_fail_fast: false,
&options.flag_test,
&options.flag_example,
&options.flag_bench),
- message_format: message_format,
+ message_format: options.flag_message_format,
target_rustdoc_args: None,
target_rustc_args: None,
},
use std::env;
use cargo::core::Workspace;
-use cargo::ops::CompileOptions;
-use cargo::ops;
+use cargo::ops::{self, CompileOptions, MessageFormat};
use cargo::util::important_paths::{find_root_manifest_for_wd};
use cargo::util::{CliResult, Config};
flag_verbose: u32,
flag_quiet: Option<bool>,
flag_color: Option<String>,
- flag_message_format: Option<String>,
+ flag_message_format: MessageFormat,
flag_release: bool,
flag_lib: bool,
flag_bin: Vec<String>,
-v, --verbose ... Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
- --message-format FMT Error format: human, json-v1
+ --message-format FMT Error format: human, json [default: human]
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
&options.flag_color,
options.flag_frozen,
options.flag_locked));
- let message_format = try!(ops::MessageFormat::from_option(
- &options.flag_message_format
- ));
let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));
&options.flag_test,
&options.flag_example,
&options.flag_bench),
- message_format: message_format,
+ message_format: options.flag_message_format,
target_rustdoc_args: None,
target_rustc_args: None,
};
use cargo::core::Workspace;
-use cargo::ops;
+use cargo::ops::{self, MessageFormat};
use cargo::util::{CliResult, Config};
use cargo::util::important_paths::{find_root_manifest_for_wd};
flag_verbose: u32,
flag_quiet: Option<bool>,
flag_color: Option<String>,
- flag_message_format: Option<String>,
+ flag_message_format: MessageFormat,
flag_package: Vec<String>,
flag_lib: bool,
flag_bin: Vec<String>,
-v, --verbose ... Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
- --message-format FMT Error format: human, json-v1
+ --message-format FMT Error format: human, json [default: human]
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
&options.flag_color,
options.flag_frozen,
options.flag_locked));
- let message_format = try!(ops::MessageFormat::from_option(
- &options.flag_message_format
- ));
let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));
&empty,
&empty,
&empty),
- message_format: message_format,
+ message_format: options.flag_message_format,
release: options.flag_release,
mode: ops::CompileMode::Doc {
deps: !options.flag_no_deps,
use cargo::core::Workspace;
-use cargo::ops;
+use cargo::ops::{self, MessageFormat};
use cargo::util::{CliResult, CliError, Config, Human};
use cargo::util::important_paths::{find_root_manifest_for_wd};
flag_verbose: u32,
flag_quiet: Option<bool>,
flag_color: Option<String>,
- flag_message_format: Option<String>,
+ flag_message_format: MessageFormat,
flag_release: bool,
flag_frozen: bool,
flag_locked: bool,
-v, --verbose ... Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
- --message-format FMT Error format: human, json-v1
+ --message-format FMT Error format: human, json [default: human]
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
&options.flag_color,
options.flag_frozen,
options.flag_locked));
- let message_format = try!(ops::MessageFormat::from_option(
- &options.flag_message_format
- ));
let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));
bins: &bins, examples: &examples,
}
},
- message_format: message_format,
+ message_format: options.flag_message_format,
target_rustdoc_args: None,
target_rustc_args: None,
};
use std::env;
use cargo::core::Workspace;
-use cargo::ops::{CompileOptions, CompileMode};
-use cargo::ops;
+use cargo::ops::{self, CompileOptions, CompileMode, MessageFormat};
use cargo::util::important_paths::{find_root_manifest_for_wd};
use cargo::util::{CliResult, CliError, Config, human};
flag_verbose: u32,
flag_quiet: Option<bool>,
flag_color: Option<String>,
- flag_message_format: Option<String>,
+ flag_message_format: MessageFormat,
flag_release: bool,
flag_lib: bool,
flag_bin: Vec<String>,
-v, --verbose ... Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
- --message-format FMT Error format: human, json-v1
+ --message-format FMT Error format: human, json [default: human]
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
&options.flag_color,
options.flag_frozen,
options.flag_locked));
- let message_format = try!(ops::MessageFormat::from_option(
- &options.flag_message_format
- ));
let root = try!(find_root_manifest_for_wd(options.flag_manifest_path,
config.cwd()));
&options.flag_test,
&options.flag_example,
&options.flag_bench),
- message_format: message_format,
+ message_format: options.flag_message_format,
target_rustdoc_args: None,
target_rustc_args: options.arg_opts.as_ref().map(|a| &a[..]),
};
use cargo::core::Workspace;
-use cargo::ops;
+use cargo::ops::{self, MessageFormat};
use cargo::util::{CliResult, Config};
use cargo::util::important_paths::{find_root_manifest_for_wd};
flag_release: bool,
flag_quiet: Option<bool>,
flag_color: Option<String>,
- flag_message_format: Option<String>,
+ flag_message_format: MessageFormat,
flag_package: Option<String>,
flag_lib: bool,
flag_bin: Vec<String>,
-v, --verbose ... Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
- --message-format FMT Error format: human, json-v1
+ --message-format FMT Error format: human, json [default: human]
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
&options.flag_color,
options.flag_frozen,
options.flag_locked));
- let message_format = try!(ops::MessageFormat::from_option(
- &options.flag_message_format
- ));
let root = try!(find_root_manifest_for_wd(options.flag_manifest_path,
config.cwd()));
&options.flag_test,
&options.flag_example,
&options.flag_bench),
- message_format: message_format,
+ message_format: options.flag_message_format,
mode: ops::CompileMode::Doc { deps: false },
target_rustdoc_args: Some(&options.arg_opts),
target_rustc_args: None,
use cargo::core::Workspace;
-use cargo::ops;
+use cargo::ops::{self, MessageFormat};
use cargo::util::{CliResult, CliError, Human, human, Config};
use cargo::util::important_paths::{find_root_manifest_for_wd};
flag_verbose: u32,
flag_quiet: Option<bool>,
flag_color: Option<String>,
- flag_message_format: Option<String>,
+ flag_message_format: MessageFormat,
flag_release: bool,
flag_no_fail_fast: bool,
flag_frozen: bool,
-v, --verbose ... Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
- --message-format FMT Error format: human, json-v1
+ --message-format FMT Error format: human, json [default: human]
--no-fail-fast Run all tests regardless of failure
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
&options.flag_color,
options.flag_frozen,
options.flag_locked));
- let message_format = try!(ops::MessageFormat::from_option(
- &options.flag_message_format
- ));
let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));
release: options.flag_release,
mode: mode,
filter: filter,
- message_format: message_format,
+ message_format: options.flag_message_format,
target_rustdoc_args: None,
target_rustc_args: None,
},
})
}
-fn flags_from_args<T>(usage: &str, args: &[String],
- options_first: bool) -> CliResult<T>
+fn flags_from_args<T>(usage: &str, args: &[String], options_first: bool) -> CliResult<T>
where T: Decodable
{
let docopt = Docopt::new(usage).unwrap()
Doc { deps: bool },
}
-#[derive(Clone, Copy, PartialEq, Eq)]
+#[derive(Clone, Copy, PartialEq, Eq, RustcDecodable)]
pub enum MessageFormat {
Human,
Json
}
-impl MessageFormat {
- pub fn from_option(opt: &Option<String>) -> CargoResult<MessageFormat> {
- match opt.as_ref().map(|s| s.as_ref()) {
- None | Some("human") => Ok(MessageFormat::Human),
- Some("json-v1") => Ok(MessageFormat::Json),
- Some(other) => bail!("argument for --message-format must be human or json-v1, \
- but found `{}`", other)
- }
- }
-}
-
pub enum CompileFilter<'a> {
Everything,
Only {
.file("bar/src/lib.rs", r#"fn dead() {}"#);
assert_that(p.cargo_process("build").arg("-v")
- .arg("--message-format").arg("json-v1"),
+ .arg("--message-format").arg("json"),
execs().with_json(r#"
{
"reason":"compiler-message",
p.build();
assert_that(p.cargo_process("build").arg("--message-format").arg("XML"),
- execs().with_status(101)
- .with_stderr_contains("\
-[ERROR] argument for --message-format must be human or json-v1, but found `XML`"));
+ execs().with_status(1)
+ .with_stderr_contains(
+r#"[ERROR] Could not match 'xml' with any of the allowed variants: ["Human", "Json"]"#));
}
#[test]